<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    #wish{
      width: 100vw;
      height: 100vh;
      background-color: #eee;
    }
    #wish p{
      position: fixed;
      width: 100px;
      min-height: 100px;
      background-color: aquamarine;
      box-shadow: 2px 2px 6px rgba(0, 0, 0, .6);
      cursor: pointer;
      user-select: none;
    }
  </style>
</head>
<body>

<div id="wish">
  <p>话题1</p>
  <p>话题2</p>
  <p>话题3</p>
  <p>话题4</p>
  <p>话题5</p>
  <p>话题6</p>
</div>

<script>
var ps = wish.querySelectorAll('p');
var index = 0;
ps.forEach(function(p){

  p.onmousedown = function(event){

    // ps.forEach(function(p){
    //   p.style.zIndex = 1;
    // })

    p.style.zIndex = ++index;
    var x1 = event.clientX;
    var y1 = event.clientY;

    var l1 = p.getBoundingClientRect().x;
    var t1 = p.getBoundingClientRect().y;

    document.onmousemove = function(event){
      
      var top = event.clientX - x1 + l1;
      var left = event.clientY - y1 + t1;

      p.style.left = top + 'px';
      p.style.top = left + 'px';

    }

    document.onmouseup = function(){
      document.onmousemove = null;
      document.onmouseup = null;
    }

  }

})


</script>
  
</body>
</html>